package com.zjh.mybase.config;

import lombok.Data;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

import javax.sql.DataSource;

//进行依赖注入包的扫描
@ComponentScan("com.zjh")
@Configuration
//加载配置文件 结合value
@PropertySource(value = "classpath:application3.properties")
@Data
@EnableAspectJAutoProxy
@Import({MybatisConfig.class,SpringMyBatisConfig.class})
@MapperScan("com.zjh")
public class SpringConfig {

    @Value("${app.version}")
    private String version;

    public SpringConfig(){
        System.out.println("配置类的构造方法");
        System.out.println(version);
    }

    @Bean
    public DataSourceTransactionManager transactionManager(DataSource dataSource) {
        return new DataSourceTransactionManager(dataSource);
    }
}
